﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using NHibernate.Criterion;
using Spring.Stereotype;
using Spring.Transaction.Interceptor;
using Spring.Data.NHibernate.Support;
using OpenSda.Core.Data;
using OpenSda.Data.NHibernateAccess;
using NHibernate;
using NHibernate.Linq;

using OpenSda.Agilcont.Common.Data.Contracts;
using OpenSda.Agilcont.Common.Data.Entities;

namespace OpenSda.Agilcont.Common.Data.NhContexts
{
    [Repository]
    public class DataAccessAgenciaConfigData : DataAccess<DataAccessAgenciaConfig>, IDataAccessAgenciaConfigData
    {
        public IQueryable<DataAccessAgenciaConfig> GetAllQueryable()
        {
            return GetDefaultSession().Query<DataAccessAgenciaConfig>();
        }

        public IList<DataAccessAgenciaConfig> GetListByFilter(string filter)
        {
            String cmd = @"FROM DataAccessAgenciaConfig ms
                            WHERE ms.Role LIKE :filter
                            OR :filter IS NULL";
            IQuery query = GetDefaultSession().CreateQuery(cmd);
            query.SetParameter("filter", filter, NHibernateUtil.AnsiString);
            return query.List<DataAccessAgenciaConfig>();
        }
    }
}